<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('student')} > ${i18n.getMessage('searchResult')}">
	<a href="#" onclick="selectAll()">${i18n.getMessage('Select All')}</a>
	- <a href="#" onclick="mergeStudent()">${i18n.getMessage('Merge')}</a>
	- <a href="#" onclick="deleteStudent()">${i18n.getMessage('Delete')}</a>
	- <a href="#" onclick="cc('student/showSearchStudent.sgt')">${i18n.getMessage('search')}</a>
</@showTitle>

<br/>

<form id="form" onreset="$('error').hide()">

<@display.table id="listTable" name="students" sort="list" defaultsort="1" pagesize="20">
	<@display.column title="${i18n.getMessage('select')}" style="text-align:center"><input type="checkbox" name="ids" value="${(listTable.id)!}"/></@display.column>
	<@display.column title="${i18n.getMessage('firstName')}" property="firstName" href="student/showInfoStudent.sgt" paramId="id" paramProperty="id" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('lastName')}" style="white-space: nowrap" property="lastName" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('nickName')}" style="white-space: nowrap" property="nickName" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('gender')}" sortable="true" style="text-align:center">${i18n.getMessage((listTable.gender.key)!)}</@display.column>
	<@display.column title="${i18n.getMessage('dateOfBirth')}" property="dateOfBirth" format="{0, date, ${i18n.getMessage('format.date')}}" sortable="true" style="text-align:center"></@display.column>
	<@display.column title="${i18n.getMessage('phoneNumber')}">${(listTable.phoneNumber)!}</@display.column>
	<@display.column title="Last Class">${(listTable.lastOffering.name)!}</@display.column>
	<@display.column title="Start Date">${(listTable.lastOffering.startDate)!}</@display.column>
	<@display.column title="${i18n.getMessage('comment')}">${(listTable.comment)!}</@display.column>
</@display.table>

</form>

<br/><br/>

<script>

selectAll = function() {
	var form = $('form');
	var count = 0;
	form.getInputs('checkbox').each(function(input) {
		if(input.checked)
			count++;
	});
	if(count > 0) {
		form.getInputs('checkbox').each(function(input) {
			input.checked = false;
		});
	}
	else {
		form.getInputs('checkbox').each(function(input) {
			input.checked = true;
		});
	}
}

deleteStudent = function() {
	var form = $('form');
	form.action = 'student/deleteSearchStudent.sgt';
	submitForm(form);
}

mergeStudent = function() {
	var form = $('form');
	form.action = 'student/mergeStudent.sgt';
	submitForm(form);
}

</script>
